package com.ruoyi.project.qyxy.plate.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.qyxy.plate.domain.SgOpenTree;
import com.ruoyi.project.qyxy.plate.service.ISgOpenTreeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 施工企业树形Controller
 * 
 * @author lcl
 * @date 2021-04-08
 */
@RestController
@RequestMapping("/qyxy/plate")
public class SgOpenTreeController extends BaseController
{
    @Autowired
    private ISgOpenTreeService sgOpenTreeService;

    /**
     * 查询施工企业树形列表
     */
    @GetMapping("/list")
    public AjaxResult list(SgOpenTree sgOpenTree)
    {
        List<SgOpenTree> list = sgOpenTreeService.selectSgOpenTreeList(sgOpenTree);
        return AjaxResult.success(list);
    }

    /**
     * 导出施工企业树形列表
     */
    @Log(title = "施工企业树形", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SgOpenTree sgOpenTree)
    {
        List<SgOpenTree> list = sgOpenTreeService.selectSgOpenTreeList(sgOpenTree);
        ExcelUtil<SgOpenTree> util = new ExcelUtil<SgOpenTree>(SgOpenTree.class);
        return util.exportExcel(list, "plate");
    }

    /**
     * 获取施工企业树形详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sgOpenTreeService.selectSgOpenTreeById(id));
    }

    /**
     * 新增施工企业树形
     */
    @Log(title = "施工企业树形", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SgOpenTree sgOpenTree)
    {
        return toAjax(sgOpenTreeService.insertSgOpenTree(sgOpenTree));
    }

    /**
     * 修改施工企业树形
     */
    @Log(title = "施工企业树形", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SgOpenTree sgOpenTree)
    {
        return toAjax(sgOpenTreeService.updateSgOpenTree(sgOpenTree));
    }

    /**
     * 删除施工企业树形
     */
    @Log(title = "施工企业树形", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sgOpenTreeService.deleteSgOpenTreeByIds(ids));
    }
}
